import argparse
import datetime
import os
today = datetime.datetime.now()
delta = datetime.timedelta(days=1)
yesterday = (today - delta).strftime("%Y-%m-%d")

parser = argparse.ArgumentParser()
parser.add_argument("--date", default=yesterday)
args = parser.parse_args()

sql = """
insert overwrite table ads.ads_member_active_consistent_count
partition (dt = \"""" + args.date + """\")
select
count(1)
from dws.dws_member_start_consistent
where dt = \"""" + args.date + """\"
"""
os.system("hive -e \'" + sql + "\'")
